package com.gisocn.onemap.ui.adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.recyclerview.widget.RecyclerView;
import com.amap.api.services.core.PoiItem;
import com.gisocn.onemap.interfaces.OnItemClickListener;
import com.gisocn.onemap.sgzx.R;
import java.util.List;

/* loaded from: classes2.dex */
public class SearchAdapter extends RecyclerView.Adapter<ViewHolder> {
    private List<PoiItem> msearchInfos;
    private OnItemClickListener onItemClickListener = null;

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes2.dex */
    public static class ViewHolder extends RecyclerView.ViewHolder {
        TextView searchAddress;
        TextView searchName;

        public ViewHolder(View view) {
            super(view);
            this.searchAddress = (TextView) view.findViewById(R.id.iv_searchAddress);
            this.searchName = (TextView) view.findViewById(R.id.iv_searchName);
        }
    }

    public SearchAdapter(List<PoiItem> list) {
        this.msearchInfos = list;
    }

    public void setOnItemClickListener(OnItemClickListener onItemClickListener) {
        this.onItemClickListener = onItemClickListener;
    }

    @Override // androidx.recyclerview.widget.RecyclerView.Adapter
    public ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
        return new ViewHolder(LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.tools_searchaddress_layout, viewGroup, false));
    }

    @Override // androidx.recyclerview.widget.RecyclerView.Adapter
    public void onBindViewHolder(ViewHolder viewHolder, final int i) {
        PoiItem poiItem = this.msearchInfos.get(i);
        viewHolder.searchName.setText(poiItem.getTitle());
        viewHolder.searchAddress.setText(poiItem.getSnippet());
        viewHolder.itemView.setOnClickListener(new View.OnClickListener() { // from class: com.gisocn.onemap.ui.adapter.SearchAdapter.1
            @Override // android.view.View.OnClickListener
            public void onClick(View view) {
                if (SearchAdapter.this.onItemClickListener != null) {
                    SearchAdapter.this.onItemClickListener.onItemClick(view, i);
                }
            }
        });
    }

    @Override // androidx.recyclerview.widget.RecyclerView.Adapter
    public int getItemCount() {
        return this.msearchInfos.size();
    }
}
